
<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <title>Step 2: Running Scan Commands Against a Server &#8212; SSLyze 3.0.8 documentation</title>
    <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
    <script src="_static/jquery.js"></script>
    <script src="_static/underscore.js"></script>
    <script src="_static/doctools.js"></script>
    <script src="_static/language_data.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="prev" title="Step 1: Testing Connectivity to a Server" href="testing-connectivity.html" />
   
  <link rel="stylesheet" href="_static/custom.css" type="text/css" />
  
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

  </head><body>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  <div class="section" id="step-2-running-scan-commands-against-a-server">
<h1>Step 2: Running Scan Commands Against a Server<a class="headerlink" href="#step-2-running-scan-commands-against-a-server" title="Permalink to this headline">¶</a></h1>
<p>Every type of scan that SSLyze can run against a server (supported cipher suites, Heartbleed, etc.) is
represented by a <code class="docutils literal notranslate"><span class="pre">ScanCommand</span></code>. Once a <code class="docutils literal notranslate"><span class="pre">ScanCommand</span></code> is run against a server, it returns a “result” object with
attributes containing the results of the scan command.</p>
<p>All the available <code class="docutils literal notranslate"><span class="pre">ScanCommands</span></code> and corresponding results are described in <a class="reference internal" href="available-scan-commands.html"><span class="doc">Appendix: Scan Commands</span></a>.</p>
<div class="section" id="basic-example">
<h2>Basic Example<a class="headerlink" href="#basic-example" title="Permalink to this headline">¶</a></h2>
<p>The main class for running these commands is the <code class="docutils literal notranslate"><span class="pre">Scanner</span></code> class, which uses a pool of workers to run
<code class="docutils literal notranslate"><span class="pre">ScanCommand</span></code> concurrently. It is very fast when scanning a large number of servers, and it has a rate-limiting
mechanism to avoid DOS-ing a single server against which multiple <code class="docutils literal notranslate"><span class="pre">ScanCommand</span></code> are run at the same time.</p>
<p>The commands can be queued by passing a <code class="docutils literal notranslate"><span class="pre">ServerScanRequest</span></code> to the <code class="docutils literal notranslate"><span class="pre">Scanner.queue_scan()</span></code> method.</p>
<p>The results can later be retrieved using the <code class="docutils literal notranslate"><span class="pre">Scanner.get_results()</span></code> method, which returns an iterable of
<code class="docutils literal notranslate"><span class="pre">ServerScanResult</span></code>. Each result is returned as soon as the server scan was completed.</p>
<p>A simple example on how to run some scan commands follows:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">basic_example</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
    <span class="c1"># Define the server that you want to scan</span>
    <span class="n">server_location</span> <span class="o">=</span> <span class="n">ServerNetworkLocationViaDirectConnection</span><span class="o">.</span><span class="n">with_ip_address_lookup</span><span class="p">(</span><span class="s2">&quot;www.google.com&quot;</span><span class="p">,</span> <span class="mi">443</span><span class="p">)</span>

    <span class="c1"># Do connectivity testing to ensure SSLyze is able to connect</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">server_info</span> <span class="o">=</span> <span class="n">ServerConnectivityTester</span><span class="p">()</span><span class="o">.</span><span class="n">perform</span><span class="p">(</span><span class="n">server_location</span><span class="p">)</span>
    <span class="k">except</span> <span class="n">ConnectionToServerFailed</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
        <span class="c1"># Could not connect to the server; abort</span>
        <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Error connecting to </span><span class="si">{</span><span class="n">server_location</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">error_message</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="c1"># Then queue some scan commands for the server</span>
    <span class="n">scanner</span> <span class="o">=</span> <span class="n">Scanner</span><span class="p">()</span>
    <span class="n">server_scan_req</span> <span class="o">=</span> <span class="n">ServerScanRequest</span><span class="p">(</span>
        <span class="n">server_info</span><span class="o">=</span><span class="n">server_info</span><span class="p">,</span> <span class="n">scan_commands</span><span class="o">=</span><span class="p">{</span><span class="n">ScanCommand</span><span class="o">.</span><span class="n">CERTIFICATE_INFO</span><span class="p">,</span> <span class="n">ScanCommand</span><span class="o">.</span><span class="n">SSL_2_0_CIPHER_SUITES</span><span class="p">},</span>
    <span class="p">)</span>
    <span class="n">scanner</span><span class="o">.</span><span class="n">queue_scan</span><span class="p">(</span><span class="n">server_scan_req</span><span class="p">)</span>

    <span class="c1"># Then retrieve the results</span>
    <span class="k">for</span> <span class="n">server_scan_result</span> <span class="ow">in</span> <span class="n">scanner</span><span class="o">.</span><span class="n">get_results</span><span class="p">():</span>
        <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">Results for </span><span class="si">{</span><span class="n">server_scan_result</span><span class="o">.</span><span class="n">server_info</span><span class="o">.</span><span class="n">server_location</span><span class="o">.</span><span class="n">hostname</span><span class="si">}</span><span class="s2">:&quot;</span><span class="p">)</span>

        <span class="c1"># SSL 2.0 results</span>
        <span class="n">ssl2_result</span> <span class="o">=</span> <span class="n">server_scan_result</span><span class="o">.</span><span class="n">scan_commands_results</span><span class="p">[</span><span class="n">ScanCommand</span><span class="o">.</span><span class="n">SSL_2_0_CIPHER_SUITES</span><span class="p">]</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">Accepted cipher suites for SSL 2.0:&quot;</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">accepted_cipher_suite</span> <span class="ow">in</span> <span class="n">ssl2_result</span><span class="o">.</span><span class="n">accepted_cipher_suites</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;* </span><span class="si">{</span><span class="n">accepted_cipher_suite</span><span class="o">.</span><span class="n">cipher_suite</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>

        <span class="c1"># Certificate info results</span>
        <span class="n">certinfo_result</span> <span class="o">=</span> <span class="n">server_scan_result</span><span class="o">.</span><span class="n">scan_commands_results</span><span class="p">[</span><span class="n">ScanCommand</span><span class="o">.</span><span class="n">CERTIFICATE_INFO</span><span class="p">]</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">Certificate info:&quot;</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">cert_deployment</span> <span class="ow">in</span> <span class="n">certinfo_result</span><span class="o">.</span><span class="n">certificate_deployments</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Leaf certificate: </span><span class="se">\n</span><span class="si">{</span><span class="n">cert_deployment</span><span class="o">.</span><span class="n">received_certificate_chain_as_pem</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="advanced-usage">
<h2>Advanced Usage<a class="headerlink" href="#advanced-usage" title="Permalink to this headline">¶</a></h2>
<p>The following script provides an example of running scan commands against multiple servers, and processing the results:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">main</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
    <span class="c1"># First validate that we can connect to the servers we want to scan</span>
    <span class="n">servers_to_scan</span> <span class="o">=</span> <span class="p">[]</span>
    <span class="k">for</span> <span class="n">hostname</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;cloudflare.com&quot;</span><span class="p">,</span> <span class="s2">&quot;google.com&quot;</span><span class="p">]:</span>
        <span class="n">server_location</span> <span class="o">=</span> <span class="n">ServerNetworkLocationViaDirectConnection</span><span class="o">.</span><span class="n">with_ip_address_lookup</span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="mi">443</span><span class="p">)</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">server_info</span> <span class="o">=</span> <span class="n">ServerConnectivityTester</span><span class="p">()</span><span class="o">.</span><span class="n">perform</span><span class="p">(</span><span class="n">server_location</span><span class="p">)</span>
            <span class="n">servers_to_scan</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">server_info</span><span class="p">)</span>
        <span class="k">except</span> <span class="n">ConnectionToServerFailed</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Error connecting to </span><span class="si">{</span><span class="n">server_location</span><span class="o">.</span><span class="n">hostname</span><span class="si">}</span><span class="s2">:</span><span class="si">{</span><span class="n">server_location</span><span class="o">.</span><span class="n">port</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">error_message</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
            <span class="k">return</span>

    <span class="n">scanner</span> <span class="o">=</span> <span class="n">Scanner</span><span class="p">()</span>

    <span class="c1"># Then queue some scan commands for each server</span>
    <span class="k">for</span> <span class="n">server_info</span> <span class="ow">in</span> <span class="n">servers_to_scan</span><span class="p">:</span>
        <span class="n">server_scan_req</span> <span class="o">=</span> <span class="n">ServerScanRequest</span><span class="p">(</span>
            <span class="n">server_info</span><span class="o">=</span><span class="n">server_info</span><span class="p">,</span> <span class="n">scan_commands</span><span class="o">=</span><span class="p">{</span><span class="n">ScanCommand</span><span class="o">.</span><span class="n">CERTIFICATE_INFO</span><span class="p">,</span> <span class="n">ScanCommand</span><span class="o">.</span><span class="n">SSL_2_0_CIPHER_SUITES</span><span class="p">},</span>
        <span class="p">)</span>
        <span class="n">scanner</span><span class="o">.</span><span class="n">queue_scan</span><span class="p">(</span><span class="n">server_scan_req</span><span class="p">)</span>

    <span class="c1"># Then retrieve the result of the scan commands for each server</span>
    <span class="k">for</span> <span class="n">server_scan_result</span> <span class="ow">in</span> <span class="n">scanner</span><span class="o">.</span><span class="n">get_results</span><span class="p">():</span>
        <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">Results for </span><span class="si">{</span><span class="n">server_scan_result</span><span class="o">.</span><span class="n">server_info</span><span class="o">.</span><span class="n">server_location</span><span class="o">.</span><span class="n">hostname</span><span class="si">}</span><span class="s2">:&quot;</span><span class="p">)</span>

        <span class="c1"># Scan commands that were run with no errors</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">ssl2_result</span> <span class="o">=</span> <span class="n">server_scan_result</span><span class="o">.</span><span class="n">scan_commands_results</span><span class="p">[</span><span class="n">ScanCommand</span><span class="o">.</span><span class="n">SSL_2_0_CIPHER_SUITES</span><span class="p">]</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">Accepted cipher suites for SSL 2.0:&quot;</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">accepted_cipher_suite</span> <span class="ow">in</span> <span class="n">ssl2_result</span><span class="o">.</span><span class="n">accepted_cipher_suites</span><span class="p">:</span>
                <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;* </span><span class="si">{</span><span class="n">accepted_cipher_suite</span><span class="o">.</span><span class="n">cipher_suite</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
        <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
            <span class="k">pass</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="n">certinfo_result</span> <span class="o">=</span> <span class="n">server_scan_result</span><span class="o">.</span><span class="n">scan_commands_results</span><span class="p">[</span><span class="n">ScanCommand</span><span class="o">.</span><span class="n">CERTIFICATE_INFO</span><span class="p">]</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">Certificate info:&quot;</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">cert_deployment</span> <span class="ow">in</span> <span class="n">certinfo_result</span><span class="o">.</span><span class="n">certificate_deployments</span><span class="p">:</span>
                <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Leaf certificate: </span><span class="se">\n</span><span class="si">{</span><span class="n">cert_deployment</span><span class="o">.</span><span class="n">received_certificate_chain_as_pem</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
        <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
            <span class="k">pass</span>

        <span class="c1"># Scan commands that were run with errors</span>
        <span class="k">for</span> <span class="n">scan_command</span><span class="p">,</span> <span class="n">error</span> <span class="ow">in</span> <span class="n">server_scan_result</span><span class="o">.</span><span class="n">scan_commands_errors</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
            <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">Error when running </span><span class="si">{</span><span class="n">scan_command</span><span class="si">}</span><span class="s2">:</span><span class="se">\n</span><span class="si">{</span><span class="n">error</span><span class="o">.</span><span class="n">exception_trace</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="module-sslyze">
<span id="related-classes"></span><h2>Related Classes<a class="headerlink" href="#module-sslyze" title="Permalink to this headline">¶</a></h2>
<dl class="py class">
<dt id="sslyze.Scanner">
<em class="property">class </em><code class="sig-prename descclassname">sslyze.</code><code class="sig-name descname">Scanner</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">per_server_concurrent_connections_limit</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">concurrent_server_scans_limit</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="headerlink" href="#sslyze.Scanner" title="Permalink to this definition">¶</a></dt>
<dd><p>The main class to use in order to call and schedule SSLyze’s scan commands from Python.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>per_server_concurrent_connections_limit</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>]) – </p></li>
<li><p><strong>concurrent_server_scans_limit</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>]) – </p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt id="sslyze.Scanner.queue_scan">
<code class="sig-name descname">queue_scan</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">server_scan</span></em><span class="sig-paren">)</span><a class="headerlink" href="#sslyze.Scanner.queue_scan" title="Permalink to this definition">¶</a></dt>
<dd><p>Queue a server scan.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>server_scan</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">ServerScanRequest</span></code>) – </p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">None</span></code></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="sslyze.Scanner.get_results">
<code class="sig-name descname">get_results</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sslyze.Scanner.get_results" title="Permalink to this definition">¶</a></dt>
<dd><p>Return completed server scans.</p>
<dl class="field-list simple">
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">Iterable</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">ServerScanResult</span></code>]</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt id="sslyze.ServerScanRequest">
<em class="property">class </em><code class="sig-prename descclassname">sslyze.</code><code class="sig-name descname">ServerScanRequest</code><span class="sig-paren">(</span><em class="sig-param">server_info</em>, <em class="sig-param">scan_commands</em>, <em class="sig-param">scan_commands_extra_arguments=&lt;factory&gt;</em><span class="sig-paren">)</span><a class="headerlink" href="#sslyze.ServerScanRequest" title="Permalink to this definition">¶</a></dt>
<dd><p>A request to scan a specific server with the supplied scan commands.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>server_info</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">ServerConnectivityInfo</span></code>) – </p></li>
<li><p><strong>scan_commands</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">Set</span></code>[<code class="xref py py-data docutils literal notranslate"><span class="pre">Literal</span></code>[‘certificate_info’, ‘ssl_2_0_cipher_suites’, ‘ssl_3_0_cipher_suites’, ‘tls_1_0_cipher_suites’, ‘tls_1_1_cipher_suites’, ‘tls_1_1_cipher_suites’, ‘tls_1_2_cipher_suites’, ‘tls_1_3_cipher_suites’, ‘tls_compression’, ‘tls_1_3_early_data’, ‘openssl_ccs_injection’, ‘tls_fallback_scsv’, ‘heartbleed’, ‘robot’, ‘session_renegotiation’, ‘session_resumption’, ‘session_resumption_rate’, ‘http_headers’]]) – </p></li>
<li><p><strong>scan_commands_extra_arguments</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">ScanCommandExtraArgumentsDict</span></code>) – </p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt id="sslyze.ServerScanResult">
<em class="property">class </em><code class="sig-prename descclassname">sslyze.</code><code class="sig-name descname">ServerScanResult</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">scan_commands_results</span></em>, <em class="sig-param"><span class="n">scan_commands_errors</span></em>, <em class="sig-param"><span class="n">server_info</span></em>, <em class="sig-param"><span class="n">scan_commands</span></em>, <em class="sig-param"><span class="n">scan_commands_extra_arguments</span></em><span class="sig-paren">)</span><a class="headerlink" href="#sslyze.ServerScanResult" title="Permalink to this definition">¶</a></dt>
<dd><p>The result of a ServerScanRequest that was completed by a Scanner.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>scan_commands_results</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">ScanCommandResultsDict</span></code>) – </p></li>
<li><p><strong>scan_commands_errors</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">Dict</span></code>[<code class="xref py py-data docutils literal notranslate"><span class="pre">Literal</span></code>[‘certificate_info’, ‘ssl_2_0_cipher_suites’, ‘ssl_3_0_cipher_suites’, ‘tls_1_0_cipher_suites’, ‘tls_1_1_cipher_suites’, ‘tls_1_1_cipher_suites’, ‘tls_1_2_cipher_suites’, ‘tls_1_3_cipher_suites’, ‘tls_compression’, ‘tls_1_3_early_data’, ‘openssl_ccs_injection’, ‘tls_fallback_scsv’, ‘heartbleed’, ‘robot’, ‘session_renegotiation’, ‘session_resumption’, ‘session_resumption_rate’, ‘http_headers’], <code class="xref py py-class docutils literal notranslate"><span class="pre">ScanCommandError</span></code>]) – </p></li>
<li><p><strong>server_info</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">ServerConnectivityInfo</span></code>) – </p></li>
<li><p><strong>scan_commands</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">Set</span></code>[<code class="xref py py-data docutils literal notranslate"><span class="pre">Literal</span></code>[‘certificate_info’, ‘ssl_2_0_cipher_suites’, ‘ssl_3_0_cipher_suites’, ‘tls_1_0_cipher_suites’, ‘tls_1_1_cipher_suites’, ‘tls_1_1_cipher_suites’, ‘tls_1_2_cipher_suites’, ‘tls_1_3_cipher_suites’, ‘tls_compression’, ‘tls_1_3_early_data’, ‘openssl_ccs_injection’, ‘tls_fallback_scsv’, ‘heartbleed’, ‘robot’, ‘session_renegotiation’, ‘session_resumption’, ‘session_resumption_rate’, ‘http_headers’]]) – </p></li>
<li><p><strong>scan_commands_extra_arguments</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">ScanCommandExtraArgumentsDict</span></code>) – </p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt id="sslyze.ScanCommandResultsDict">
<em class="property">class </em><code class="sig-prename descclassname">sslyze.</code><code class="sig-name descname">ScanCommandResultsDict</code><a class="headerlink" href="#sslyze.ScanCommandResultsDict" title="Permalink to this definition">¶</a></dt>
<dd><p>A dictionary of results for every scan command that was scheduled against a specific server.</p>
<dl class="py attribute">
<dt id="sslyze.ScanCommandResultsDict.certificate_info">
<code class="sig-name descname">certificate_info</code><em class="property">: CertificateInfoScanResult</em><em class="property"> = None</em><a class="headerlink" href="#sslyze.ScanCommandResultsDict.certificate_info" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt id="sslyze.ScanCommandResultsDict.ssl_2_0_cipher_suites">
<code class="sig-name descname">ssl_2_0_cipher_suites</code><em class="property">: CipherSuitesScanResult</em><em class="property"> = None</em><a class="headerlink" href="#sslyze.ScanCommandResultsDict.ssl_2_0_cipher_suites" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt id="sslyze.ScanCommandResultsDict.ssl_3_0_cipher_suites">
<code class="sig-name descname">ssl_3_0_cipher_suites</code><em class="property">: CipherSuitesScanResult</em><em class="property"> = None</em><a class="headerlink" href="#sslyze.ScanCommandResultsDict.ssl_3_0_cipher_suites" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt id="sslyze.ScanCommandResultsDict.tls_1_0_cipher_suites">
<code class="sig-name descname">tls_1_0_cipher_suites</code><em class="property">: CipherSuitesScanResult</em><em class="property"> = None</em><a class="headerlink" href="#sslyze.ScanCommandResultsDict.tls_1_0_cipher_suites" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt id="sslyze.ScanCommandResultsDict.tls_1_1_cipher_suites">
<code class="sig-name descname">tls_1_1_cipher_suites</code><em class="property">: CipherSuitesScanResult</em><em class="property"> = None</em><a class="headerlink" href="#sslyze.ScanCommandResultsDict.tls_1_1_cipher_suites" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt id="sslyze.ScanCommandResultsDict.tls_1_2_cipher_suites">
<code class="sig-name descname">tls_1_2_cipher_suites</code><em class="property">: CipherSuitesScanResult</em><em class="property"> = None</em><a class="headerlink" href="#sslyze.ScanCommandResultsDict.tls_1_2_cipher_suites" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt id="sslyze.ScanCommandResultsDict.tls_1_3_cipher_suites">
<code class="sig-name descname">tls_1_3_cipher_suites</code><em class="property">: CipherSuitesScanResult</em><em class="property"> = None</em><a class="headerlink" href="#sslyze.ScanCommandResultsDict.tls_1_3_cipher_suites" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt id="sslyze.ScanCommandResultsDict.tls_compression">
<code class="sig-name descname">tls_compression</code><em class="property">: CompressionScanResult</em><em class="property"> = None</em><a class="headerlink" href="#sslyze.ScanCommandResultsDict.tls_compression" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt id="sslyze.ScanCommandResultsDict.tls_1_3_early_data">
<code class="sig-name descname">tls_1_3_early_data</code><em class="property">: EarlyDataScanResult</em><em class="property"> = None</em><a class="headerlink" href="#sslyze.ScanCommandResultsDict.tls_1_3_early_data" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt id="sslyze.ScanCommandResultsDict.openssl_ccs_injection">
<code class="sig-name descname">openssl_ccs_injection</code><em class="property">: OpenSslCcsInjectionScanResult</em><em class="property"> = None</em><a class="headerlink" href="#sslyze.ScanCommandResultsDict.openssl_ccs_injection" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt id="sslyze.ScanCommandResultsDict.tls_fallback_scsv">
<code class="sig-name descname">tls_fallback_scsv</code><em class="property">: FallbackScsvScanResult</em><em class="property"> = None</em><a class="headerlink" href="#sslyze.ScanCommandResultsDict.tls_fallback_scsv" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt id="sslyze.ScanCommandResultsDict.heartbleed">
<code class="sig-name descname">heartbleed</code><em class="property">: HeartbleedScanResult</em><em class="property"> = None</em><a class="headerlink" href="#sslyze.ScanCommandResultsDict.heartbleed" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt id="sslyze.ScanCommandResultsDict.robot">
<code class="sig-name descname">robot</code><em class="property">: RobotScanResult</em><em class="property"> = None</em><a class="headerlink" href="#sslyze.ScanCommandResultsDict.robot" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt id="sslyze.ScanCommandResultsDict.session_renegotiation">
<code class="sig-name descname">session_renegotiation</code><em class="property">: SessionRenegotiationScanResult</em><em class="property"> = None</em><a class="headerlink" href="#sslyze.ScanCommandResultsDict.session_renegotiation" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt id="sslyze.ScanCommandResultsDict.session_resumption">
<code class="sig-name descname">session_resumption</code><em class="property">: SessionResumptionSupportScanResult</em><em class="property"> = None</em><a class="headerlink" href="#sslyze.ScanCommandResultsDict.session_resumption" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt id="sslyze.ScanCommandResultsDict.session_resumption_rate">
<code class="sig-name descname">session_resumption_rate</code><em class="property">: SessionResumptionRateScanResult</em><em class="property"> = None</em><a class="headerlink" href="#sslyze.ScanCommandResultsDict.session_resumption_rate" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt id="sslyze.ScanCommandResultsDict.http_headers">
<code class="sig-name descname">http_headers</code><em class="property">: HttpHeadersScanResult</em><em class="property"> = None</em><a class="headerlink" href="#sslyze.ScanCommandResultsDict.http_headers" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

<dl class="py attribute">
<dt id="sslyze.ScanCommandErrorsDict">
<code class="sig-prename descclassname">sslyze.</code><code class="sig-name descname">ScanCommandErrorsDict</code><a class="headerlink" href="#sslyze.ScanCommandErrorsDict" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt id="sslyze.ScanCommandErrorReasonEnum">
<em class="property">class </em><code class="sig-prename descclassname">sslyze.</code><code class="sig-name descname">ScanCommandErrorReasonEnum</code><a class="headerlink" href="#sslyze.ScanCommandErrorReasonEnum" title="Permalink to this definition">¶</a></dt>
<dd><p>An enumeration.</p>
<dl class="py attribute">
<dt id="sslyze.ScanCommandErrorReasonEnum.BUG_IN_SSLYZE">
<code class="sig-name descname">BUG_IN_SSLYZE</code><em class="property"> = 1</em><a class="headerlink" href="#sslyze.ScanCommandErrorReasonEnum.BUG_IN_SSLYZE" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt id="sslyze.ScanCommandErrorReasonEnum.CLIENT_CERTIFICATE_NEEDED">
<code class="sig-name descname">CLIENT_CERTIFICATE_NEEDED</code><em class="property"> = 2</em><a class="headerlink" href="#sslyze.ScanCommandErrorReasonEnum.CLIENT_CERTIFICATE_NEEDED" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt id="sslyze.ScanCommandErrorReasonEnum.CONNECTIVITY_ISSUE">
<code class="sig-name descname">CONNECTIVITY_ISSUE</code><em class="property"> = 3</em><a class="headerlink" href="#sslyze.ScanCommandErrorReasonEnum.CONNECTIVITY_ISSUE" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt id="sslyze.ScanCommandErrorReasonEnum.WRONG_USAGE">
<code class="sig-name descname">WRONG_USAGE</code><em class="property"> = 4</em><a class="headerlink" href="#sslyze.ScanCommandErrorReasonEnum.WRONG_USAGE" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="exporting-to-json">
<h2>Exporting to JSON<a class="headerlink" href="#exporting-to-json" title="Permalink to this headline">¶</a></h2>
<p>A <code class="docutils literal notranslate"><span class="pre">ServerScanResult</span></code> can be serialized to JSON using SSLyze’s special <code class="docutils literal notranslate"><span class="pre">JsonEncoder</span></code>.</p>
<dl class="py class">
<dt id="sslyze.JsonEncoder">
<em class="property">class </em><code class="sig-prename descclassname">sslyze.</code><code class="sig-name descname">JsonEncoder</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span></em>, <em class="sig-param"><span class="n">skipkeys</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">ensure_ascii</span><span class="o">=</span><span class="default_value">True</span></em>, <em class="sig-param"><span class="n">check_circular</span><span class="o">=</span><span class="default_value">True</span></em>, <em class="sig-param"><span class="n">allow_nan</span><span class="o">=</span><span class="default_value">True</span></em>, <em class="sig-param"><span class="n">sort_keys</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">indent</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">separators</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">default</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="headerlink" href="#sslyze.JsonEncoder" title="Permalink to this definition">¶</a></dt>
<dd><p>Special JSON encoder that can serialize any ServerScanResult returned by SSLyze.</p>
<p>A ServerScanResult can be serialized to JSON using the following code:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">dataclasses</span> <span class="kn">import</span> <span class="n">asdict</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">json</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">sslyze</span>
<span class="go">&gt;&gt;&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">scanner</span> <span class="o">=</span> <span class="n">sslyze</span><span class="o">.</span><span class="n">Scanner</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># Queue some ServerScanRequest... and then retrieve the results...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">server_scan_result</span> <span class="ow">in</span> <span class="n">scanner</span><span class="o">.</span><span class="n">get_results</span><span class="p">():</span>
<span class="gp">&gt;&gt;&gt; </span>    <span class="n">server_scan_result_as_json</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">asdict</span><span class="p">(</span><span class="n">server_scan_result</span><span class="p">),</span> <span class="bp">cls</span><span class="o">=</span><span class="n">sslyze</span><span class="o">.</span><span class="n">JsonEncoder</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

</div>
</div>


          </div>
          
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="index.html">SSLyze</a></h1>








<h3>Navigation</h3>
<ul>
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation of SSLyze</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="available-scan-commands.html">Appendix: Scan Commands</a></li>
</ul>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="testing-connectivity.html">Step 1: Testing Connectivity to a Server</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Step 2: Running Scan Commands Against a Server</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#basic-example">Basic Example</a></li>
<li class="toctree-l2"><a class="reference internal" href="#advanced-usage">Advanced Usage</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-sslyze">Related Classes</a></li>
<li class="toctree-l2"><a class="reference internal" href="#exporting-to-json">Exporting to JSON</a></li>
</ul>
</li>
</ul>

<div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="index.html">Documentation overview</a><ul>
      <li>Previous: <a href="testing-connectivity.html" title="previous chapter">Step 1: Testing Connectivity to a Server</a></li>
  </ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" />
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>








        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;Copyright 2020 Alban Diquet.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 3.0.4</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
      
      |
      <a href="_sources/running-scan-commands.rst.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>